﻿<template>
    <div class="container" style="width:99%;margin-top:-25px;">
        <!-- 查询条件 -->
        <div class="query-box">
            <el-form :model="queryBox" status-icon ref="queryBox">
                <div class="schoolBoxCont">
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">学校名称</div>
                            <div class="schoolBoxContItemInput">
                                <el-input clearable v-model="queryBox.name" placeholder="学校名称"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">联系电话</div>
                            <div class="schoolBoxContItemInput">
                                <el-input clearable v-model="queryBox.phone" placeholder="联系电话"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">大区经理</div>
                            <div class="schoolBoxContItemInput">
                                <el-select
                                    v-model="queryBox.belongToId"
                                    filterable
                                    placeholder="请选择"
                                    value-key="id"
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item in userName"
                                        :key="item.id"
                                        :label="item.realName"
                                        :value="item.id"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">三级部门</div>
                            <div class="schoolBoxContItemInput">
                                <el-select
                                    v-model="queryBox.thirdLevelDepartment"
                                    clearable
                                    filterable
                                    @change="changeThree"
                                >
                                    <el-option
                                        v-for="item in threeDept"
                                        :key="item.id"
                                        :label="item.deptName"
                                        :value="item.id"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>

                    <!-- <div class="schoolBoxContItem">
            <el-form-item label prop="name">
              <div class="schoolBoxContItemTitle">
                三方分成比例
              </div>
              <div class="schoolBoxContItemInput">
                <el-input
                  clearable
                  v-model="queryBox.thirdProportion"
                  placeholder="三方分成比例"
                  @change="Proportion"
                >
                </el-input>
              </div>
            </el-form-item>
                    </div>-->
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">三方姓名</div>
                            <div class="schoolBoxContItemInput">
                                <el-select
                                    filterable
                                    v-model="queryBox.thirdPatry"
                                    clearable
                                    placeholder="请选择"
                                >
                                    <el-option
                                        v-for="item in schoolTripartiteTypeOption"
                                        :key="item.key"
                                        :label="item.value"
                                        :value="item.key"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">意向程度</div>
                            <div class="schoolBoxContItemInput">
                                <el-select clearable filterable v-model="queryBox.type">
                                    <el-option
                                        v-for="item in student_type_options"
                                        :key="item.key"
                                        :label="item.value"
                                        :value="item.key"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">是否报备</div>
                            <div class="schoolBoxContItemInput">
                                <el-select clearable filterable v-model="queryBox.isRecord">
                                    <el-option
                                        v-for="item in isRecord_type_options"
                                        :key="item.key"
                                        :label="item.value"
                                        :value="item.key"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">审核状态</div>
                            <div class="schoolBoxContItemInput">
                                <el-select clearable filterable v-model="queryBox.auditStatus">
                                    <el-option
                                        v-for="item in school_audit_status_option"
                                        :key="item.key"
                                        :label="item.value"
                                        :value="item.key"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">今日应跟进</div>
                            <div class="schoolBoxContItemInput">
                                <el-select
                                    clearable
                                    @change="isTodayTrackingChange"
                                    v-model="queryBox.isTodayTracking"
                                    filterable
                                >
                                    <el-option
                                        v-for="item in isTodayTracking_options"
                                        :key="item.lable"
                                        :label="item.value"
                                        :value="item.label"
                                    ></el-option>
                                </el-select>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle" style="width:115px">应跟进时间</div>
                            <div class="schoolBoxContItemInput" style="width:428px">
                                <el-date-picker
                                    v-model="todayTrackingDate"
                                    type="daterange"
                                    range-separator="至"
                                    start-placeholder="开始日期"
                                    end-placeholder="结束日期"
                                    :default-time="['00:00:00', '23:59:59']"
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                ></el-date-picker>
                            </div>
                        </el-form-item>
                    </div>
                    <div class="schoolBoxContItem">
                        <el-form-item label prop="name">
                            <div class="schoolBoxContItemTitle">所在地区：</div>
                            <div class="schoolBoxContItemInput" style="width:300px">
                                <el-cascader
                                    clearable
                                    style="width:100% !important"
                                    size="large"
                                    :options="options"
                                    v-model="selectedOptions"
                                ></el-cascader>
                            </div>
                        </el-form-item>
                    </div>
                </div>
            </el-form>
            <div class="from-btns">
                <kt-button
                    :label="$t('action.reset')"
                    perms="true"
                    type="primary"
                    @click="reset('queryBox')"
                />
                <kt-button
                    :label="$t('action.search')"
                    perms="true"
                    type="primary"
                    @click="get_subcentersearch"
                />
            </div>
        </div>
        <!-- 批量删除按钮 -->
        <div class="add-btns fl">
            <kt-button
                label="移入客户公海"
                :perms="btnDelete"
                :size="size"
                type="danger"
                @click="handleBatchDelete"
                :disabled="this.selections.length === 0"
                style="float:left;"
            />
            <!-- perms="directCampCenter:myschool:delete" -->
        </div>
        <div class="fr" style="margin-bottom:20px">
            <kt-button
                :label="$t('action.download-tmpl')"
                type="primary"
                :perms="btnDownload"
                @click="downloadTmpl"
            ></kt-button>
            <!-- perms="directCampCenter:myschool:download" -->
            <kt-button
                :label="$t('action.batchimport')"
                type="primary"
                :perms="btnBatchimport"
                @click="customerManagerImport"
            ></kt-button>
            <!-- perms="directCampCenter:myschool:batchimport" -->
            <el-button type="primary" @click="openAsking" size="mini">学校查询</el-button>
            <kt-button label="新增学校" type="primary" :perms="btnAdd" @click="handleNewADD"></kt-button>
        </div>
        <!-- 查重 -->
        <Checkrepeat
            @colsePop="colsePop"
            @openAsking="openAsking"
            :checkrepeatShow="checkrepeatShow"
            :checkloading="checkloading"
        ></Checkrepeat>
        <!--表格内容栏-->
        <div class="btn">
            <Crm-table
                @selectionChange="selectionChange"
                class="table-width"
                Mycustomerschool
                width="400"
                :permsEdit="tableBtnEdit"
                :permsSee="tableBtnSee"
                :permsReport="tableBtnReport"
                :data="pageResult"
                :columns="columns"
                :loading="loading"
                @findPage="findPage"
                @changeSwitch="changeSwitch"
                @handleEdit="handleEdit"
                @handleSee="handleSee"
                @handleFollow="handleFollow"
                @handleReport="handleReport"
                @handleAudit="handleAudit"
            ></Crm-table>
            <!-- permsEdit="directCampCenter:myschool:edit"
            permsSee="directCampCenter:myschool:see"
            permsReport="directCampCenter:myschool:report"-->
        </div>
        <!-- 报备 -->
        <el-dialog
            :title="recordData.name"
            width="70%"
            :visible.sync="reportShow"
            :close-on-click-modal="false"
            @close="recordDataPopClose"
            class="pop"
        >
            <div class="second-contain-box ma school-pop second-contain-box2">
                <el-row>
                    <el-col :span="3">
                        <el-col :span="16">
                            <i>拜访次数：</i>
                        </el-col>
                        <el-col :span="8">
                            <span>{{ recordData.visitNum }}</span>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="8">
                            <i>
                                <em style="color:red">*</em> 拜访/宴请/参会时间：
                            </i>
                        </el-col>
                        <el-col :span="14">
                            <el-date-picker
                                v-model="recordData.trackingDateStart"
                                type="date"
                                style="margin-top:-10px"
                                placeholder="选择日期"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </el-col>
                    </el-col>
                    <el-col :span="9">
                        <el-col :span="6">
                            <i>
                                <em style="color:red">*</em> 跟进类型：
                            </i>
                        </el-col>
                        <el-col :span="18">
                            <el-select
                                style="width:100%;margin-top:-10px"
                                v-model="recordData.recordTypeObj"
                                placeholder="请选择"
                                clearable
                                @change="recordTypeChange"
                                @clear="recordTypeClear"
                            >
                                <el-option
                                    v-for="item in school_recordType_options"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row v-for="item in infoData" :key="item.id">
                    <el-col :span="24">
                        <el-col :span="24">
                            <el-col :span="3">
                                <i>
                                    <em style="color:red" v-if="item.isRequired==1">*</em>
                                    {{item.detailName}}
                                </i>
                            </el-col>
                            <el-col :span="21">
                                <el-input
                                    style="width:100%"
                                    type="textarea"
                                    :rows="2"
                                    placeholder="请输入内容"
                                    v-model="item.content"
                                ></el-input>
                            </el-col>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <em style="color:red">*</em>下次跟进日期：
                        </el-col>
                        <el-col :span="14">
                            <el-date-picker
                                v-model="recordData.nextRecordDate"
                                type="date"
                                style="margin-top:-10px"
                                placeholder="选择日期"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                            ></el-date-picker>
                        </el-col>
                    </el-col>
                </el-row>
            </div>
            <kt-button
                class="stu-btn"
                :label="$t('action.save')"
                perms="true"
                size="medium"
                type="primary"
                @click="handleSaveRecord()"
            />
            <p class="tracking-tit">跟进情况</p>
            <Crm-table
                seeSchoolTracking
                :showBatchDelete="showBatchDelete"
                class="tracking-table"
                :data="detailRecordInfoData"
                :columns="columns3"
                @handleSee="handleSee2"
                @findPage="findPage3"
                :loading="loading"
            ></Crm-table>
        </el-dialog>
        <!-- 跟进  弃用-->
        <el-dialog
            :title="saveData.name"
            width="70%"
            :visible.sync="addFollow"
            :close-on-click-modal="false"
        >
            <div class="second-contain-box ma school-pop">
                <el-row>
                    <el-col :span="12">
                        <el-col :span="12">
                            <i style="margin-top:0">跟进次数：{{ saveData.trackingNum }}</i>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="8">
                            <i style="margin-top:0">跟进时间：</i>
                        </el-col>
                        <el-col :span="16">
                            <span>{{ saveData.trackingDate }}</span>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>联系人：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-input placeholder="请输入内容" v-model="saveData.contactTrack"></el-input>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>沟通形式：</i>
                        </el-col>
                        <el-col :span="18">
                            <el-select
                                style="width:100%"
                                v-model="saveData.communicationType"
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="item in student_communication_type"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>客户类型：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-select
                                style="width:100%"
                                :disabled="typeDisabled"
                                v-model="saveData.type"
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="item in student_type_options"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="6">
                            <i>客户进展：</i>
                        </el-col>
                        <el-col :span="18">
                            <el-select
                                style="width:100%"
                                :disabled="selectDisabled"
                                v-model="saveData.progress"
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="item in student_progress_options"
                                    :key="item.value"
                                    :label="item.value"
                                    :value="item.key"
                                ></el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-col :span="24">
                            <el-col :span="3">
                                <i>沟通内容：</i>
                            </el-col>
                            <el-col :span="21">
                                <el-input
                                    style="width:100%"
                                    type="textarea"
                                    :rows="2"
                                    placeholder="请输入内容"
                                    v-model="saveData.communicationContent"
                                ></el-input>
                            </el-col>
                        </el-col>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <i style="margin-top:5%">跟进人：{{ trackingPeople }}</i>
                    </el-col>
                    <el-col :span="12">
                        <el-col :span="8">
                            <i>下次跟进日期：</i>
                        </el-col>
                        <el-col :span="16">
                            <el-date-picker
                                style="width:100%"
                                v-model="saveData.nextTrackingDate"
                                type="datetime"
                                placeholder="选择日期时间"
                                :default-time="mytime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                format="yyyy-MM-dd HH:mm:ss"
                                :picker-options="pickerOptions"
                            ></el-date-picker>
                        </el-col>
                    </el-col>
                </el-row>
            </div>
            <kt-button
                class="stu-btn"
                :label="$t('action.save')"
                perms="true"
                size="medium"
                type="primary"
                @click="handleSave()"
            />
            <p class="tracking-tit">跟进情况</p>
            <Crm-table
                :showBatchDelete="showBatchDelete"
                class="tracking-table"
                :data="stuqueryTrackingData"
                :columns="columns2"
                @findPage2="findPage2"
                :loading="loading"
            ></Crm-table>
        </el-dialog>
        <!--导入-->
        <el-dialog
            :title="'批量导入'"
            width="30%"
            :visible.sync="uploadOem"
            :close-on-click-modal="false"
        >
            <el-form :model="form">
                <el-form-item>
                    <el-upload
                        ref="uploadExcel"
                        :action="uploadUrl"
                        :limit="limitNum"
                        :auto-upload="false"
                        accept=".xls"
                        :before-upload="beforeUploadFile"
                        :on-change="fileChange"
                        :on-exceed="exceedFile"
                        :on-success="handleSuccess"
                        :on-error="handleError"
                        :file-list="fileList"
                        :on-remove="handleRemove"
                    >
                        <el-button size="small" plain>选择文件上传</el-button>
                        <div slot="tip" class="el-upload__tip">只能上传xls(Excel97-2004)文件</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button :size="size" @click.native="uploadOem = false">
                    {{
                    $t("action.cancel")
                    }}
                </el-button>
                <el-button :size="size" type="primary" @click.native="uploadFile">
                    {{
                    $t("立即上传")
                    }}
                </el-button>
            </div>
        </el-dialog>
        <!-- 跟进详情 -->
        <el-dialog
            title="跟进详情"
            :visible.sync="dialogVisible"
            width="30%"
            :before-close="handleCloseDialogVisible"
        >
            <div class="trckingList">
                <ul>
                    <li v-for="item in rowData.recordPlans">
                        <span class="title">{{item.recordName}}</span>
                        :{{item.recordContent}}
                    </li>
                </ul>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import KtButton from "@/views/Core/KtButton";
import StTable from "@/views/Core/StTable";
import CrmTable from "@/views/Core/CrmTable";
import CrmSwitch from "@/views/Core/CrmSwitch";
import { CodeToText } from "element-china-area-data";
import { baseUrl } from "@/utils/global";
import { regionDataPlus } from "element-china-area-data";
import axios from "axios";
import Checkrepeat from "@/views/Core/Checkrepeat";
import Cookies from "js-cookie";
export default {
    name: "School",
    components: {
        PopupTreeInput,
        CrmTable,
        KtButton,
        CrmSwitch,
        Checkrepeat
    },
    beforeMount: function() {
        let dataType = "";
        if (this.$route.fullPath.indexOf("dataType=2") > -1) {
            dataType = 2;
        }
        this.$api.agent.myTripartiteList({ dataType: dataType }).then(res => {
            if (res.result == 2) {
                this.$message({ message: res.msg, type: "error" });
            } else {
                this.schoolTripartiteTypeOption = res.data;
            }
        });
    },
    data() {
        return {
            isShowFlag: 0, //0:初始化部门、人员不显示  1:部门显示 2：人员显示
            showBatchDelete: false,
            mytime: "",
            size: "mini",
            selectDisabled: false, //跟进弹窗客户进展状态
            typeDisabled: false,
            schoolSectionArr: [], //学段数组
            filters: {
                name: ""
            },
            todayTrackingDate: [],
            uploadOem: false, //文件上传
            limitNum: 1, //上传最大个数
            form: {
                file: ""
            },
            isTodayTracking: "",
            fileList: [],
            uploadUrl: baseUrl + "/file/upload", //文件上传地址
            downloadTmplUrl: baseUrl + "/template/schoolImportTemplate.xlsx", //模板下载地址
            // 查询条件
            student_data_from_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            // 客户跟进数据
            stuqueryTrackingData: {
                content: []
            },
            // 报备数据
            detailRecordInfoData: {
                content: []
            },
            // 查询条件
            student_data_from_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_progress_options: [
                {
                    label: " ",
                    key: " "
                }
            ],
            student_data_from_type_options: [
                {
                    label: " ",
                    key: " "
                }
            ],

            isRecord_type_options: [
                {
                    key: "1",
                    value: "已报备"
                },
                {
                    key: "2",
                    value: "未报备"
                }
            ],
            isTodayTracking_options: [
                {
                    value: "是",
                    label: "1"
                }
            ],

            student_level_cache_options: [
                {
                    key: " ",
                    value: " "
                }
            ],
            createDateArr: [], // 创建时间数组
            trackingDateArr: [], //跟进时间数组
            student_communication_type: [],
            queryBox: {
                name: "",
                contact: "",
                peopleNum: "",
                schoolSystem: "",
                type: "",
                duty: "",
                phone: "",
                thirdProportion: 0,
                thirdName: "",
                thirdPhone: "",
                thirdContractSignedDate: "",
                thirdContractEndDate: "",
                paymentSituation: "",
                feastNum: "",
                mettingNum: "",
                visitNum: "",
                thirdLevelDepartment: "",
                isRecord: "",
                auditStatus: "",
                trackingDateStart: "",
                isTodayTracking: "",
                thirdPatry: ""
            },
            columns: [
                { type: "index", label: "序号", minWidth: 50 },
                { prop: "name", label: "学校名称", minWidth: 100 },
                { prop: "peopleNum", label: "学校人数", minWidth: 100 },
                { prop: "contact", label: "学校负责人", minWidth: 100 },
                { prop: "duty", label: "职位", minWidth: 100 },
                { prop: "phone", label: "手机", minWidth: 120 },
                {
                    prop: "thirdProportion",
                    label: "三方分成比例",
                    minWidth: 100
                },
                { prop: "thirdName", label: "三方姓名", minWidth: 100 },
                { prop: "thirdPhone", label: "三方手机", minWidth: 100 },
                {
                    prop: "thirdContractSignedDate",
                    label: "合同签署时间",
                    minWidth: 120
                },
                {
                    prop: "thirdContractEndDate",
                    label: "合同到期时间",
                    minWidth: 120
                },
                { prop: "paymentSituation", label: "回款情况", minWidth: 100 },
                { prop: "feastNum", label: "宴请次数", minWidth: 100 },
                { prop: "mettingNum", label: "参会次数", minWidth: 100 },
                { prop: "visitNum", label: "拜访次数", minWidth: 100 },
                { prop: "record", label: "是否报备", minWidth: 100 },
                { prop: "auditStatusStr", label: "审核状态", minWidth: 100 },
                { prop: "diqu", label: "地区", minWidth: 190 },
                {
                    prop: "createDate",
                    sortable: "true",
                    label: "创建时间",
                    minWidth: 140
                }
                // {
                //   prop: "trackingDate",
                //   sortable: "true",
                //   label: "最新跟进时间",
                //   minWidth: 140
                // }
            ],
            columns2: [
                { type: "index", label: "序号", minWidth: 10 },
                { prop: "trackingDate", label: "跟进时间", minWidth: 100 },
                { prop: "contactTrack", label: "联系人", minWidth: 50 },
                { prop: "typeTrack", label: "客户类型", minWidth: 80 },
                { prop: "progressTrack", label: "客户进展", minWidth: 50 },
                { prop: "communicationType", label: "沟通形式", minWidth: 50 },
                {
                    prop: "communicationContent",
                    label: "沟通内容",
                    minWidth: 120
                },
                {
                    prop: "nextTrackingDateDetail",
                    label: "下次跟进时间",
                    minWidth: 100
                }
            ],
            columns3: [
                { type: "index", label: "序号", minWidth: 10 },
                {
                    prop: "trackingDateStart",
                    label: "拜访/宴请/参会时间",
                    minWidth: 100
                },
                { prop: "recordType", label: "报备类别", minWidth: 100 }
            ],
            pageResult: {
                content: []
            },
            operation: false, // true:新增, false:编辑
            batchdistribution: false, //显示批量分配弹窗
            selectionsLength: "",
            selections: [], //选中列表集合
            ids: [], //分配ID集合
            deptData: [], //部门树
            deptTree: {
                label: "deptName",
                children: "children"
            },
            addFollow: false, //显示跟进窗口
            deptinputValue: "",
            // 划分方式
            deptmodeoptions: [
                {
                    label: "分配至部门",
                    value: "11"
                },
                {
                    label: "分配至个人",
                    value: "9"
                }
            ],

            deptuseroption: [], //部门用户
            addstuformData: {},
            deptmodeoptionsValue: "",

            AllotData: {
                assignType: 2,
                schoolIds: "",
                thirdLevelDepartment: "",
                belongToId: "",
                belong_to_type: ""
            },
            // 地区
            options: regionDataPlus,
            selectedOptions: [],
            saveData: {
                type: "",
                dataFrom: "",
                progress: "",
                code: "",
                name: "",
                schoolSection: "",
                belongToId: "",
                thirdPatry: "",
                isLock: "",
                createDateStart: "", //创建开始时间
                createDateEnd: "", //创建结束时间
                trackingDateStart: "", //最新跟进开始时间
                trackingDateEnd: "", //最新跟进结束时间
                orderName: "",
                orderType: "",
                id: "",
                progress: "",
                belongToName: "",
                belongToId: Cookies.get("userId"),
                communicationType: ""
            },
            trackingPeople: Cookies.get("realName"),
            loading: false, // 加载标识
            // 限制跟进时间
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
                }
            },
            pageRequest2: {
                pageNum: 1,
                pageSize: 10
            },
            checkrepeatShow: false,
            checkloading: false,
            checkMessage: "",
            isLoadingSuccess: false,
            reportShow: false,
            recordData: {
                trackingDate: "",
                expectedClosingDate: ""
            },
            queryTrackingRecordData: {},
            threeDept: [],
            school_recordType_options: [],
            userName: [],
            school_audit_status_option: [],
            auditStatus: "",
            infoData: [],
            rowData: [],
            dialogVisible: false,
            pageRequest3: {
                pageNum: 1,
                pageSize: 10
            },
            nextTrackingDate: [],
            schoolTripartiteTypeOption: [],
            dataType: this.$route.fullPath.indexOf("dataType=2") > -1 ? 2 : "", // 根据参数动态添加权限按钮
            btnAdd: "",
            btnBatchimport: "",
            btnDelete: "",
            btnDownload: "",
            tableBtnEdit: "",
            tableBtnSee: "",
            tableBtnReport: ""
        };
    },
    methods: {
        transformRouteBtnParam() {
            if (this.dataType && this.dataType == 2) {
                this.btnAdd = "directCampCenter:tz:myschool:add";
                this.btnBatchimport =
                    "directCampCenter:tz:myschool:batchimport";
                this.btnDelete = "directCampCenter:tz:myschool:delete";
                this.btnDownload = "directCampCenter:tz:myschool:download";
                (this.tableBtnEdit = "directCampCenter:tz:myschool:edit"),
                    (this.tableBtnSee = "directCampCenter:tz:myschool:see"),
                    (this.tableBtnReport =
                        "directCampCenter:tz:myschool:report");
            } else {
                this.btnAdd = "directCampCenter:myschool:add";
                this.btnBatchimport = "directCampCenter:myschool:batchimport";
                this.btnDelete = "directCampCenter:myschool:delete";
                this.btnDownload = "directCampCenter:myschool:download";
                this.tableBtnEdit = "directCampCenter:myschool:edit";
                this.tableBtnSee = "directCampCenter:myschool:see";
                this.tableBtnReport = "directCampCenter:myschool:report";
            }
        },
        // 客户类型
        get_student_type() {
            this.student_type_options = JSON.parse(
                localStorage.getItem("schoolType")
            );
            this.school_audit_status_option = JSON.parse(
                localStorage.getItem("schoolAuditStatus")
            );
        },
        isTodayTrackingChange() {
            this.getServerTime();
            // this.queryBox.todayStart=
            // this.queryBox.todayEnd=
        },
        // 客户来源
        get_student_data_from() {
            this.student_data_from_options = JSON.parse(
                localStorage.getItem("schoolSource")
            );
        },
        getServerTime() {
            this.$api.dict.getTime().then(res => {
                this.saveData.trackingDate = res.data;

                this.queryBox.todayStart = res.data;
                this.queryBox.todayEnd = res.data;
            });
        },
        get_dataTime() {
            let dateTime = new Date();
            let mytime = dateTime.toLocaleTimeString("chinese", {
                hour12: false
            }); //获取当前时间
            this.mytime = mytime;
        },
        // 获取方式
        get_student_data_from_type() {
            this.student_data_from_type_options = JSON.parse(
                localStorage.getItem("schoolDataFromType")
            );
        },

        // 客户进展
        get_student_progress() {
            this.student_progress_options = JSON.parse(
                localStorage.getItem("schoolProgress")
            );
        },

        student_progress_change(value) {
            this.queryBox.student_progressValue = value.toString();
        },

        // 学段
        get_level_cache() {
            this.student_level_cache_options = JSON.parse(
                localStorage.getItem("schoolSection")
            );
        },

        // 获取分页数据
        findPage: function(data) {
            if (data !== null) {
                this.loading = true;
                this.pageRequest = data.pageRequest;
            }
            if (this.todayTrackingDate.length > 0) {
                this.queryBox.todayStart = this.todayTrackingDate[0];
                this.queryBox.todayEnd = this.todayTrackingDate[1];
                // this.queryBox.isTodayTracking='1'
            }
            //如果创建时间查询的时候选择了，给查询参数赋值
            if (this.createDateArr.length > 0) {
                this.queryBox.createDateStart = this.createDateArr[0];
                this.queryBox.createDateEnd = this.createDateArr[1];
            }

            //如果跟进时间查询的时候选择了，给查询参数赋值
            if (this.trackingDateArr.length > 0) {
                this.queryBox.trackingDateStart = this.trackingDateArr[0];
                this.queryBox.trackingDateEnd = this.trackingDateArr[1];
            }
             // 跟进日期降序
            this.queryBox.orderName='tracking_date',
            this.queryBox.orderType='desc'
            this.queryBox.queryInterface = 4;
            this.queryBox.pageNum = this.pageRequest.pageNum;
            this.queryBox.pageSize = this.pageRequest.pageSize;
            if (this.schoolSectionArr.length > 0) {
                this.queryBox.schoolSection = this.schoolSectionArr.join(",");
            } else if (this.schoolSectionArr.length == 0) {
                this.queryBox.schoolSection = "";
            }
            let dataType = "";
            // 获取参数判断是否是商务拓展中心
            // if(this.$route.fullPath.indexOf('dataType=2'==-1)){}
            // if (this.$route.fullPath=='/DirectCampCenter/MySchool/dataType=2') {
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                dataType = 2;
            }
            if (dataType == 2) {
                this.queryBox.dataType = 2;
            }
            this.$api.school
                .myCustomerQueryList(this.queryBox)
                .then(res => {
                    let content = {
                        content: res.listSchoolInfo,
                        totalSize: res.total
                    };
                    this.pageResult = content;
                    this.pageResult.content.forEach(item => {
                        item.thirdProportion = item.thirdProportion + "%";
                        // 去掉时间的时分秒
                        item.thirdContractSignedDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.thirdContractSignedDate
                        );
                        item.thirdContractEndDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.thirdContractEndDate
                        );
                        //转换地区
                        if (
                            (item.province == null && item.city == null) ||
                            (item.province == "null" && item.city == "null")
                        ) {
                            item.diqu = "";
                        } else {
                            item.diqu =
                                CodeToText[item.province] +
                                CodeToText[item.city] +
                                CodeToText[item.area];
                        }
                        // 是否报备
                        if (item.isRecord == 1) {
                            item.record = "已报备";
                        } else {
                            item.record = "未报备";
                        }
                        // 审核状态  1: 未提交  2:审核中 3:审核通过  4:审核驳回
                        if (item.auditStatus == 1) {
                            item.auditStatusStr = "未提交";
                        }
                        if (item.auditStatus == 2) {
                            item.auditStatusStr = "审核中";
                        }
                        if (item.auditStatus == 3) {
                            item.auditStatusStr = "审核通过";
                        }
                        if (item.auditStatus == 4) {
                            item.auditStatusStr = "审核驳回";
                        }
                        if (item.auditStatus == 0) {
                            item.auditStatusStr = "审核通过";
                        }

                        //转换来源
                        this.student_data_from_options.forEach(type_item => {
                            if (type_item.key == item.dataFrom) {
                                item.laiyuan = type_item.value;
                            }
                        });
                        //转换客户类型
                        this.student_type_options.forEach(type_item => {
                            if (type_item.key == item.type) {
                                item.type2 = item.type;
                                item.type = type_item.value;
                            }
                        });

                        //转换客户进展
                        this.student_progress_options.forEach(type_item => {
                            if (type_item.key == item.progress) {
                                item.jinzhan = type_item.value;
                            }
                        });

                        // 转换学段
                        if (
                            item.schoolSection != "" &&
                            item.schoolSection != null
                        ) {
                            let schoolSection = item.schoolSection.split(",");
                            let sectionStr = "";
                            schoolSection.forEach((schoolSection, index) => {
                                this.student_level_cache_options.forEach(
                                    level_cache => {
                                        if (level_cache.key == schoolSection) {
                                            sectionStr =
                                                sectionStr +
                                                level_cache.value +
                                                ",";
                                        }
                                    }
                                );
                            });
                            item.xueDuan = sectionStr.substring(
                                0,
                                sectionStr.lastIndexOf(",")
                            );
                        }
                    });

                    this.loading = false;
                })
                .then(data != null ? data.callback : "");
        },

        // 查询学生跟进列表
        findPage2(data) {
            if (data !== null) {
                this.pageRequest2 = data.pageRequest;
            }
            this.$api.school
                .schooldetail({
                    id: this.saveData.schoolId,
                    pageSize: this.pageRequest2.pageSize,
                    pageNum: this.pageRequest2.pageNum
                })
                .then(res => {
                    let content = {
                        content: res.trackLists,
                        totalSize: res.total
                    };
                    this.stuqueryTrackingData = content;
                    this.stuqueryTrackingData.content.forEach(item => {
                        this.student_type_options.forEach(type_item => {
                            if (type_item.key == item.typeTrack) {
                                item.typeTrack = type_item.value;
                            }
                        });

                        this.student_progress_options.forEach(progress_item => {
                            if (progress_item.key == item.progressTrack) {
                                item.progressTrack = progress_item.value;
                            }
                        });

                        this.student_type_options.forEach(type_item => {
                            if (type_item.key == item.customerType) {
                                item.customerType = type_item.value;
                            }
                        });

                        this.student_communication_type.forEach(
                            communication_item => {
                                if (
                                    communication_item.key ==
                                    item.communicationType
                                ) {
                                    item.communicationType =
                                        communication_item.value;
                                }
                            }
                        );
                    });
                })
                .then(data != null ? data.callback : "");
        },
        // 查询报备列表
        findPage3(data) {
            if (data !== null) {
                this.pageRequest3 = data.pageRequest;
            }

            this.$api.school
                .detailRecordInfo({
                    id: this.recordData.schoolId,
                    pageSize: this.pageRequest3.pageSize,
                    pageNum: this.pageRequest3.pageNum
                })
                .then(res => {
                    let content = {
                        content: res.trackLists,
                        totalSize: res.total
                    };
                    this.detailRecordInfoData = content;
                    this.detailRecordInfoData.content.forEach(item => {
                        this.school_recordType_options.forEach(type_item => {
                            if (type_item.key == item.recordType) {
                                item.recordType = type_item.value;
                            }
                        });
                        item.trackingDateStart = /\d{4}-\d{1,2}-\d{1,2}/g.exec(
                            item.trackingDateStart
                        );
                    });
                })
                .then(data != null ? data.callback : "");
        },
        // 搜索
        get_subcentersearch() {
            this.loading = true;
            this.queryBox.province = this.selectedOptions[0];
            this.queryBox.city = this.selectedOptions[1];
            this.queryBox.area = this.selectedOptions[2];
            this.pageRequest.pageNum = 1;
            this.findPage(null);
        },

        // 重置
        reset(queryBox) {
            // this.$refs.queryBox.resetFields();
            this.queryBox.name = "";
            this.queryBox.contact = "";
            this.queryBox.peopleNum = "";
            this.queryBox.schoolSystem = "";
            this.queryBox.type = "";
            this.queryBox.duty = "";
            this.queryBox.phone = "";
            this.queryBox.thirdProportion = 0;
            this.queryBox.thirdName = "";
            this.queryBox.thirdPhone = "";
            this.queryBox.thirdContractSignedDate = "";
            this.queryBox.thirdContractEndDate = "";
            this.queryBox.paymentSituation = "";
            this.queryBox.feastNum = "";
            this.queryBox.mettingNum = "";
            this.queryBox.visitNum = "";
            this.queryBox.selectedOptions = [];
            this.queryBox.province = "";
            this.queryBox.thirdLevelDepartment = "";
            this.queryBox.belongToId = "";
            this.selectedOptions = [];
            this.queryBox.city = "";
            this.queryBox.area = "";
            this.queryBox.isRecord = "";
            this.queryBox.auditStatus = "";
            this.queryBox.thirdPatry = "";
            this.queryBox.todayStart = "";
            this.queryBox.todayEnd = "";
            this.todayTrackingDate = [];
            this.queryBox.isTodayTracking = "";
            this.pageRequest.pageNum = 1;

            this.findPage(null);
        },
        // 批量分配
        handlebatchdistribution(params) {
            this.batchdistribution = true;
            this.ids = [];
            let idstu = this.selections.map(item => item.id);
            this.ids = idstu;
        },

        // 批量分配提交
        batchdistributionsubmit() {
            this.AllotData.schoolIds = this.ids;
            this.$api.school.schoolAssign(this.AllotData).then(res => {
                if (res.result === 1) {
                    this.$message({ message: res.msg, type: "success" });
                    this.batchdistribution = false;
                    this.findPage(null);
                } else {
                    this.$message({ message: res.msg, type: "error" });
                }
            });
        },

        // 批量删除
        handleBatchDelete() {
            let schids = this.selections.map(item => item.id);
            this.$confirm(
                "确认将" + this.selections.length + "个客户移入到公海吗？",
                "提示",
                {}
            ).then(() => {
                this.editLoading = true;
                this.$api.school
                    .removeTo({
                        schoolIds: this.ids
                        // dateType: 4
                    })
                    .then(res => {
                        if (res.result == 1) {
                            this.$message({
                                message: res.msg,
                                type: "success"
                            });
                            this.findPage(null);
                        } else {
                            this.$message({ message: res.msg, type: "error" });
                        }
                    });
            });
        },

        // 解锁锁定
        changeSwitch: function(data) {
            this.$api.school
                .schoolInfoLock({
                    schoolId: data.row.id,
                    isLock: data.row.isLock
                })
                .then(res => {
                    if (res.result == 1) {
                        this.$message({ message: res.msg, type: "success" });

                        //执行查询接口，刷新列表信息
                        this.queryBox.queryInterface = 4;
                        this.queryBox.pageNum = this.pageRequest.pageNum;
                        this.queryBox.pageSize = this.pageRequest.pageSize;
                        this.$api.school
                            .cusomerschoolList(this.queryBox)
                            .then(res => {
                                this.pageResult.content = res.listSchoolInfo;
                            })
                            .then(data != null ? data.callback : "");
                    } else {
                        this.$message({ message: res.msg, type: "error" });
                    }
                });
        },

        // 批量导入
        customerManagerImport: function() {
            this.uploadOem = true;
            if (this.form.file != "") {
                this.$refs.uploadExcel.clearFiles();
                this.form.file = "";
            }
        },
        // 文件超出个数限制时的钩子
        exceedFile(files, fileList) {
            this.$notify.warning({
                title: "警告",
                message: `只能选择 ${
                    this.limitNum
                } 个文件，当前共选择了 ${files.length + fileList.length} 个`
            });
        },
        // 文件状态改变时的钩子
        fileChange(file, fileList) {
            this.form.file = file.raw;
        },
        // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
        beforeUploadFile(file) {
            let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
            let size = file.size / 1024 / 1024;
            if ((extension !== "xlsx") & "xls") {
                this.$notify.warning({
                    title: "警告",
                    message: `只能上传Excel97-2004（即后缀是.xls）的文件`
                });
            }
        },
        // 文件上传成功时的钩子
        handleSuccess(res, file, fileList) {
            this.$refs.uploadExcel.clearFiles();
            this.form.file = "";
            this.$notify.success({
                title: "成功",
                message: `文件上传成功,数据处理中,稍后在我的消息中查看！`
            });
        },
        // 文件上传失败时的钩子
        handleError(err, file, fileList) {
            this.$notify.error({
                title: "错误",
                message: `文件上传失败`
            });
        },
        uploadFile() {
            let formData = new FormData();
            formData.append("file", this.form.file);
            let dataType = "";
            // 获取参数判断是否是商务拓展中心
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                // if (this.$route.query.dataType) {
                dataType = 2;
            }
            axios
                .post(this.uploadUrl, formData, {
                    "Content-Type": "multipart/form-data"
                })
                .then(res => {
                    if (res.data.result == 1) {
                        let path = res.data.fileUrl;
                        this.$api.school
                            .myCustomerImport({
                                path: path,
                                dataType: dataType
                            })
                            .then(res => {
                                if (res.result == 2) {
                                    this.$message({
                                        message: res.msg,
                                        type: "error"
                                    });
                                    this.handleError();
                                } else {
                                    this.$message({
                                        message: res.msg,
                                        type: "success"
                                    });
                                    this.handleSuccess();
                                }
                                this.uploadOem = false;
                                this.findPage(null);
                            });
                    } else {
                        this.handleError();
                    }
                });
        },

        // 删除上传列表操作
        handleRemove(file, fileList) {
            this.form.file = "";
        },

        // 下载模板
        downloadTmpl() {
            this.getSchoolTempl();
        },

        // 获取部门数据
        get_dept_data() {
            this.$api.dropdown.deptLevel3().then(res => {
                this.deptData = res.departmentInfoList;
            });
        },

        //划分方式 控制部门人员显示
        deptmodeoptionsChange(value) {
            if (value == 9) {
                this.isShowFlag = 2;
                this.AllotData.belong_to_type = 1; //个人
                this.AllotData.thirdLevelDepartment = 0; //清空
            } else if (value == 11) {
                this.isShowFlag = 1;
                this.AllotData.belong_to_type = 2; //部门
                this.AllotData.belongToId = 0;
            } else {
                this.isShowFlag = 0;
            }
        },

        // 点击部门
        handleTreeSelectChange3Add(data, node) {
            this.deptinputValue = data.deptName;
            this.AllotData.thirdLevelDepartment = data.id;
            this.AllotData.belongToId = data.id;
            this.AllotData.belongToId = "";
            this.get_dept_user();
        },

        // 获取部门用户
        get_dept_user() {
            this.$api.student
                .queryUserList({
                    get_dept_user: this.AllotData.thirdLevelDepartment
                })
                .then(res => {
                    this.deptuseroption = res.userInfoList;
                });
        },

        // 查看客户档案
        handleSee: function(params) {
            this.dataForm = Object.assign({}, params.row);
            this.$router.push({
                path: "/Customerfile/School",
                query: {
                    id: this.dataForm.id
                }
            });
        },
        handleSee2(params) {
            this.dialogVisible = true;
            this.rowData = params.row;
        },
        handleCloseDialogVisible() {
            this.dialogVisible = false;
            this.recordData.recordType = "";
        },
        // 修改客户档案
        handleEdit: function(params) {
            this.dataForm = Object.assign({}, params.row);
            let dataType = "";
            // 获取参数判断是否是商务拓展中心
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                // if (this.$route.query.dataType) {
                dataType = 2;
            }
            this.$router.push({
                path: "/Customerfile/EditSchool",
                query: {
                    id: this.dataForm.id,
                    recordInfoId: params.row.recordInfoId,
                    auditStatus: params.row.auditStatus,
                    dataType: dataType
                }
            });
        },

        // 获取选中的表格数据
        selectionChange: function(params) {
            let selectionsLength = params.selections.length;
            this.selections = params.selections;

            this.ids = [];
            let idstu = this.selections.map(item => item.id);
            this.ids = idstu;
        },

        // 新增客户
        handleNewADD: function() {
            let dataType = "";
            // 获取参数判断是否是商务拓展中心
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                // if (this.$route.query.dataType) {
                dataType = 2;
            }
            this.$router.push({
                path: "/Customerfile/AddSchool",
                query: {
                    createType: "4",
                    dataType: dataType
                }
            });
        },
        // 查看客户档案
        handleSee: function(params) {
            this.dataForm = Object.assign({}, params.row);
            this.$router.push({
                path: "/Customerfile/School",
                query: {
                    id: this.dataForm.id
                }
            });
        },
        // 客户跟进
        handleFollow: function(params) {
            this.pageRequest2.pageNum = "1";
            this.agentName = params.row.agentName;
            this.addFollow = true;
            this.saveData.schoolId = params.row.id;
            this.saveData.trackingNum = params.row.trackingNum;
            this.saveData.name = params.row.name;
            this.saveData.contactTrack = params.row.name;
            this.saveData.communicationType = "1";
            this.saveData.type = params.row.type;
            this.saveData.progress = params.row.progress;
            this.getServerTime();
            this.findPage2(null);
        },
        // 报备
        handleReport: function(params) {
            this.reportShow = true;
            this.schoolVisitType();
            // this.infoData.forEach(item => {
            //     item.planCode = item.detailCode;
            //     item.recordName = item.detailName;
            //     item.recordContent = item.content;
            // });

            
            this.recordData.name = params.row.name;
            this.recordData.schoolId = params.row.id;
            this.recordData.feastNum = params.row.feastNum;
            this.recordData.mettingNum = params.row.mettingNum;
            this.recordData.visitNum = params.row.visitNum;
            this.recordData.belongToId = params.row.belongToId;
            this.recordData.belongToName = params.row.belongToName;
            this.findPage3(null);
        },
        // 报备类别
        schoolVisitType() {
            this.school_recordType_options = JSON.parse(
                localStorage.getItem("schoolRecordTypeOptions")
            );
        },
        // 获取地区
        handleChange(value) {
            this.schoolInfo.city = value;
        },
        handleSaveRecord() {
            this.getServerTime();
            this.infoData.forEach(item => {
                item.recordContent = item.content;
            });
            this.recordData.trackingPlan = this.infoData;
            try {
                this.infoData.forEach(item => {
                    if (item.isRequired == 1) {
                        if (item.recordContent == "" || !item.recordContent) {  
                            this.$message({
                                message: item.detailName + "不能为空！",
                                type: "error"
                            });
                            throw new Error("ending")
                        }
                    }
                });
            } catch (e) {
                if(e.message == "ending"){
                    return
                }else{
                    
                }
            }
            this.$api.school.saveRecord(this.recordData).then(res => {
                if (res.result == 1) {
                    this.$message({
                        message: res.msg,
                        type: "success"
                    });
                    this.recordData.recordType = "";
                    this.recordData.recordTypeObj = "";
                    this.recordData.trackingDate = [];
                    this.infoData = "";
                    this.recordData.recordContent = "";
                    this.recordData.nextPlan = "";
                    this.recordData.majorDifficulty = "";
                    this.recordData.neededSupport = "";
                    this.recordData.competitor = "";
                    this.recordData.charge = "";
                    this.recordData.expectedClosingDate = "";
                    this.recordData.plannedPeopleNum = "";
                    this.recordData.trackingDateStart = "";
                    this.recordData.nextRecordDate = "";
                    this.reportShow = false;
                } else {
                    this.$message({
                        message: res.msg,
                        type: "error"
                    });
                }
            });
            
        },
        recordDataPopClose() {
            this.recordData.recordType = "";
            this.recordData.recordTypeObj = "";
            this.recordData.trackingDate = [];
            this.infoData = "";
        },
        // 提交跟进数据
        handleSave() {
            this.$api.school.saveTrack(this.saveData).then(res => {
                if (res.result != 1) {
                    this.$message({
                        message: res.msg,
                        type: "error"
                    });
                } else {
                    this.$message({
                        message: res.msg,
                        type: "success"
                    });
                    this.addFollow = false;
                    this.saveData.progress = "";
                    this.saveData.type = "";
                    this.saveData.nextTrackingDate = "";
                    this.saveData.communicationContent = "";
                    this.saveData.communicationType = "";
                    this.saveData.contactTrack = "";
                    this.recordData.recordType = "";
                    this.findPage(null);
                }
            });
        },
        // 获取时间
        dateFormat: function(time) {
            var date = new Date(time);
            var year = date.getFullYear();
            /* 在日期格式中，月份是从0开始的，因此要加0
             * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
             * */
            var month =
                date.getMonth() + 1 < 10
                    ? "0" + (date.getMonth() + 1)
                    : date.getMonth() + 1;
            var day =
                date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var hours =
                date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minutes =
                date.getMinutes() < 10
                    ? "0" + date.getMinutes()
                    : date.getMinutes();
            var seconds =
                date.getSeconds() < 10
                    ? "0" + date.getSeconds()
                    : date.getSeconds();
            // 拼接
            return (
                year +
                "-" +
                month +
                "-" +
                day +
                " " +
                hours +
                ":" +
                minutes +
                ":" +
                seconds
            );
        },
        // 沟通形式
        get_contractType() {
            this.$api.school.school_communication_type().then(res => {
                this.student_communication_type = res.keyValueList;
            });
            this.saveData.belongToName = this.trackingPeople;
        },
        // 关闭索要弹窗
        colsePop(val) {
            this.checkrepeatShow = false;
        },
        openAsking() {
            this.checkrepeatShow = true;
        },
        Proportion(val) {
            if (val != 0) {
                if (val > 100) {
                    this.$message({
                        message: "请输入正确的分成比例！",
                        type: "error"
                    });
                    this.queryBox.thirdProportion = 0;
                    return false;
                }
                this.queryBox.thirdProportion = val;
                this.isSffc = !this.isSffc;
            } else if (val == 0 || val > 100 || val == "") {
                this.isSffc = !this.isSffc;
                this.queryBox.thirdProportion = 0;
            }
        },
        // 大区经理远程搜索
        querySearchAsync2(queryString, callback) {
            let restaurants = [{}];
            let results = "";
            this.$api.student.querySignRep().then(res => {
                let signRepListJson = [];
                for (let i = 0; i < res.signRepList.length; i++) {
                    let j = {};
                    j.name = res.signRepList[i];
                    signRepListJson.push(j);
                }
                for (let i of signRepListJson) {
                    i.value = i.name; //将想要展示的数据作为value
                }
                restaurants = signRepListJson;
                results = queryString
                    ? restaurants.filter(this.createFilter2(queryString))
                    : restaurants;
                callback(results);
            });
        },
        createFilter2(queryString) {
            return restaurant => {
                return (
                    restaurant.name
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0
                );
            };
        },
        handleSelect2(item) {
            
            this.queryBox.belongToId = item.id;
        },
        //三级部门改变
        changeThree: function(value) {
            this.queryBox.thirdLevelDepartment = value;
        },
        // 获取三级部门
        get_threeDept() {
            var  deptType=''
            if (this.$route.fullPath.indexOf("dataType=2") > -1) {
                deptType = 5;
            }else{
                deptType = 4
            }
            this.$api.user.queryDepartmentListtz({deptLevel: 3,deptType:deptType}).then(res => {
                this.threeDept = res.departmentInfoList;
            });
            this.$api.dropdown
                .users({ userType: 3, deptType: deptType, accountStatus: 1 })
                .then(res => {
                    if (res.result == 1) {
                        this.userName = res.userInfoList;
                    }
                });
        },
        // 提交审核
        handleAudit(params) {
            this.$confirm("确定提交报备？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                this.$api.school
                    .commitAudit({ schoolId: params.row.id })
                    .then(res => {
                        if (res.result == 1) {
                            this.$message({
                                message: res.msg,
                                type: "success"
                            });
                            this.findPage(null);
                        } else {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            });
                        }
                    });
            });
        },
        // 选择跟进类型
        recordTypeChange(params) {
            this.recordData.recordType = params.key;
            this.saveData.recordType = params.key;
            this.getRecordType(params);
        },
        // 清空
        recordTypeClear() {
            this.infoData = [];
        },
        // 根据跟进类型请求要添加的项目
        getRecordType(params) {
            this.$api.agent
                .queryTrackingKV({
                    codeType: "school_visit_type",
                    key: params.key
                })
                .then(res => {
                    if (res.result == 2) {
                        // this.$message({ message: res.msg, type: "error" });
                    } else {
                        this.infoData = res.data;
                        // this.$message({ message: res.msg, type: 'success' });
                    }
                });
        }
    },
    mounted() {
        this.transformRouteBtnParam();
        this.get_student_type();
        this.get_student_data_from();
        this.get_student_data_from_type();
        this.get_student_progress();
        this.get_level_cache();
        this.get_dataTime();
        this.get_contractType();
        this.get_threeDept();
    }
};
</script>
<style>
@import url("../../assets/queryBox.css");
</style>
<style lang="scss" scope>
.trckingList {
    ul {
        padding-left: 0;
        li {
            list-style: none;
            text-align: left;
            line-height: 30px;
            .title {
                font-weight: bold;
            }
        }
    }
}
.add-btns .el-button:nth-child(1) {
    margin-right: 10px;
}
.second-contain-box {
    width: 95%;
    margin: 0 auto;
    .el-col {
        text-align: left;
        margin: 4px 0;
    }
    .el-row {
        margin: 0 0 !important;
    }
    .el-col i {
        font-style: normal;
        display: inline-block;
    }
}
.second-contain-box2 {
    .el-col i {
        margin-top: 0px !important;
    }
}
.schoolBoxCont {
    margin: 5px 5px;

    .schoolBoxContItem {
        margin-right: 10px;
        float: left;
        .el-form-item__content {
            display: flex;
            flex-direction: row;
        }
        .schoolBoxContItemTitle {
            background: #f5f7fa;
            width: 115px;
            border: 1px solid #dcdfe6;
            border-top-left-radius: 4px;
            border-bottom-left-radius: 4px;
            line-height: 39px;
            border-right: none;
        }
        .schoolBoxContItemInput {
            width: 150px;
            line-height: 39px;
            .el-date-editor.el-input,
            .el-date-editor.el-input__inner {
                width: 100%;
            }
        }
    }
}
.pop {
    .el-range-editor.el-input__inner {
        width: 100%;
    }
}
</style>
